$(document).ajaxSend(function (e, xhr, opt) {
    let userToken = localStorage.getItem("token");
    xhr.setRequestHeader("user_token", userToken);
});

$(document).ajaxError(function (event, xhr, options, exc) {
    if (xhr.status == 401) {
        location.href = "blog_login.html";
    }
});

function getUserInfo(url) {
    $.ajax({
        type: "get",
        url: url,
        success: function (result) {
            if (result.code == 200 && result.data != null) {
                $(".left .card h3").text(result.data.userName);
                $(".left .card a").attr("href", result.data.githubUrl);
            } else {
                //TODO  自己完成
            }
        }
    });
}
function logout(){
    localStorage.removeItem("loginUserId");
    localStorage.removeItem("token");
    location.href = "blog_login.html";

}